package joomz;

/**
 * @see Action
 * @see Direction
 * @see Item
 * @see Location
 * @see Object
 * @see Type
 */
public final class Enumerated<V extends Abstract>
    extends java.util.HashMap<String,V>
{
    /**
     * 
     */
    public interface Member {}


    public Enumerated(){
        super();
    }


    public boolean register(V object){
        if (null == this.get(object.id)){
            String id = object.id;
            if (null == this.get(id))
                this.put(id,object);

            id = id.toLowerCase();
            if (null == this.get(id))
                this.put(id,object);

            id = object.label;
            if (null == this.get(id))
                this.put(id,object);

            id = id.toLowerCase();
            if (null == this.get(id))
                this.put(id,object);

            return true;
        }
        else
            return false;
    }
    public V forName(String string){
        if (null != string){
            V v = this.get(string);
            if (null == v){
                string = string.toLowerCase();
                return this.get(string);
            }
            else
                return v;
        }
        else
            return null;
    }
}
